<template>
  <tr>
    <td><input type="checkbox" v-model="obj.checked" /></td>
    <td>{{ obj.name }}</td>
    <td>{{ obj.price }}</td>
    <td>
      <!-- 减 -->
      <button @click="removeFn(obj, index)">-</button>
      {{ obj.num }}
      <!-- 加 -->
      <button @click="addFn(obj, index)">+</button>
    </td>
    <td>{{ obj.price * obj.num }}</td>
    <td><button @click="clickFn(index)">删除</button></td>
  </tr>
</template>

<script>
export default {
  props: {
    obj: {},
    index: 0,
  },
  methods: {
    clickFn(index) {
      this.$emit("isAll", index);
    },
    addFn(obj, ind) {
      obj.num = obj.num + 1;
      this.$emit("createFn", obj.num, ind);
    },
    removeFn(obj, index) {
      if (obj.num > 1) {
        obj.num = obj.num - 1;
        this.$emit("jjFn", obj.num, ind);
      }
    },
  },
};
</script>

<style scoped>
</style>